import Service from '@/api/httpAxios'

export interface modifyAlias {
  project_id: string
  alias_id: string
  UpdateAliasRequestBody: any
}

export interface aliasMsg {
  project_id: string
  alias_id: string
}

class lts {
  createLts = (obj: any) => {
    let pid
    obj.project_id ? (pid = obj.project_id) : (pid = localStorage.getItem('project_id'))
    const url = `/v1/${pid}/lts-access-config`
    return Service.post<any>(url, obj)
  }
  createTransfer = (obj: any) => {
    let pid
    obj.project_id ? (pid = obj.project_id) : (pid = localStorage.getItem('project_id'))
    const url = `/v1/${pid}/lts-transfer`
    return Service.post<any>(url, obj)
  }
  deleteLts = (obj: any) => {
    let pid
    obj.project_id ? (pid = obj.project_id) : (pid = localStorage.getItem('project_id'))
    const url = `/v1/${pid}/lts-access-config/?access_config_id=${obj.access_config_id}`
    return Service.delete<any>(url)
  }
  deleteLtsT = (obj: any) => {
    let pid
    obj.project_id ? (pid = obj.project_id) : (pid = localStorage.getItem('project_id'))
    const url = `/v1/${pid}/lts-transfer/?log_transfer_id=${obj.log_transfer_id}`
    return Service.delete<any>(url)
  }
  getLts = (obj: any) => {
    let params: { [key: string]: string | number } = {}
    let pid
    obj.id ? (pid = obj.id) : (pid = localStorage.getItem('project_id'))
    const url = `/v1/${pid}/list-lts-access-config`
    if (obj.offset) params['offset'] = obj.offset - 1
    if (obj.limit) params['limit'] = obj.limit
    return Service.get<any>(url, {
      params
    })
  }
  getLtsDetails = (obj: any) => {
    let pid
    obj.id ? (pid = obj.id) : (pid = localStorage.getItem('project_id'))
    const url = `/v1/${pid}/lts-access-config?access_config_id=${obj.access_config_id}`
    return Service.get<any>(url)
  }
  getLtsTDetails = (obj: any) => {
    let pid
    obj.id ? (pid = obj.id) : (pid = localStorage.getItem('project_id'))
    const url = `/v1/${pid}/list-lts-transfer?log_stream_id=${obj.log_stream_id}`
    return Service.get<any>(url)
  }
  getltsLogGroup = (obj: any) => {
    let pid
    obj.id ? (pid = obj.id) : (pid = localStorage.getItem('project_id'))
    const url = `/v1/${pid}/list-lts-log-group`
    return Service.get<any>(url)
  }
  createltsLogGroup = (obj: any) => {
    let pid
    obj.project_id ? (pid = obj.project_id) : (pid = localStorage.getItem('project_id'))
    const url = `/v1/${pid}/lts-log-group`
    return Service.post<any>(url, obj)
  }
}

export default new lts()
